From f697b8c68d56fb2acb66accacb449b7bcb49d838 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Mon, 5 Dec 2016 12:36:44 -0500 Subject: [PATCH] Add more structure to the warnings returned from crates.io publish --- src/cargo/ops/registry.rs | 6 +++--- src/crates-io/lib.rs | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index 2b4447609..4c9bad817 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -151,13 +151,13 @@ fn transmit(config: &Config, }, tarball); match publish { - Ok(invalid_categories) => { - if !invalid_categories.is_empty() { + Ok(warnings) => { + if !warnings.invalid_categories.is_empty() { let msg = format!("\ the following are not valid category slugs and were \ ignored: {}. Please see https://crates.io/category_slugs \ for the list of all category slugs. \ - ", invalid_categories.join(", ")); + ", warnings.invalid_categories.join(", ")); config.shell().warn(&msg)?; } Ok(()) diff --git a/src/crates-io/lib.rs b/src/crates-io/lib.rs index e35d82440..00637be3d 100644 --- a/src/crates-io/lib.rs +++ b/src/crates-io/lib.rs @@ -111,6 +111,10 @@ pub struct User { pub name: Option, } +pub struct Warnings { + pub invalid_categories: Vec, +} + #[derive(RustcDecodable)] struct R { ok: bool } #[derive(RustcDecodable)] struct ApiErrorList { errors: Vec } #[derive(RustcDecodable)] struct ApiError { detail: String } @@ -155,7 +159,7 @@ impl Registry { } pub fn publish(&mut self, krate: &NewCrate, tarball: &File) - -> Result> { + -> Result { let json = json::encode(krate)?; // Prepare the body. The format of the upload request is: // @@ -215,7 +219,7 @@ impl Registry { x.iter().flat_map(Json::as_string).map(Into::into).collect() }) .unwrap_or_else(Vec::new); - Ok(invalid_categories) + Ok(Warnings { invalid_categories: invalid_categories }) } pub fn search(&mut self, query: &str, limit: u8) -> Result<(Vec, u32)> { -- 2.30.2